package com.carpedil.shirodemo.system.controller;

import com.carpedil.shirodemo.system.model.Menu;
import com.carpedil.shirodemo.system.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class IndexController {

  @Autowired private IMenuService menuService;

  @GetMapping(value = {"/", "/index", "/main"})
  public String index(Model model) {
    List<Menu> menus = menuService.selectCurrentUserMenuTree();
    model.addAttribute("menus", menus);
    return "index";
  }

  @GetMapping("/welcome")
  public String welcome() {
    return "welcome";
  }
}
